#pragma once
#include <memory>
#include <map>
#include <mutex>
#include "VDecoder.h"

namespace Media{
//should get from video sdk
#define MAX_DECODER_NUM 16
    class VDecoderManager{
    public:
        using DecChannel = int;
        using DecEnabled = bool;
        using Ptr = std::shared_ptr<VDecoderManager>;
        static Ptr Instance();
        VDecoderManager();
        ~VDecoderManager();

        bool CreateDecoder(VDecoder::Ptr& ptr);
        bool ReleaseDecoder(const VDecoder::Ptr& ptr);

    private:
        bool getAvailableChannel(DecChannel& channel);

        std::map<DecChannel, DecEnabled> m_decoders;
        std::recursive_mutex m_mux;
    };

}